package com.sphd.emanu.activity.dis;

import android.content.Context;

import com.google.gson.JsonObject;
import com.sphd.emanu.mvp.BasePresenterImpl;
import com.wzutils.L;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class DisPresenter extends BasePresenterImpl<DisContract.View> implements DisContract.Presenter{

    @Override
    public void updateDiscount(Integer id, Boolean enabled, Integer discountRate, Boolean advanceEnabled, Integer advanceRate, Integer advanceTime, Boolean isLoop) {
        emanuService.updateDiscount(id, enabled, discountRate, advanceEnabled, advanceRate, advanceTime, isLoop)
                .enqueue(new Callback<JsonObject>() {
                    @Override
                    public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
                        L.e(response.toString());
                        mView.upRes(res(response));
                    }

                    @Override
                    public void onFailure(Call<JsonObject> call, Throwable t) {
                    Error(t);
                    }
                });
    }
}
